<template>
    <el-dialog
        v-model="tenantAuthDeleteDialogVisible"
        title="删除用户授权"
        width="20%"
        align-center
        :show-close="false"
        :close-on-click-modal="false"
    >
        是否确定删除？
        <template #footer>
            <div class="dialog-footer">
                <el-button @click="cancelDialog()">取 消</el-button>
                <el-button type="primary" :loading="deleteLoading" @click="submitDialog()">
                    确认
                </el-button>
            </div>
        </template>
    </el-dialog>
</template>

<script name="TenantAuthDeleteDialog" setup lang="ts">
import {tenantAuthInfoDelete, tenantAuthInfoQuery} from "@/request/tenant";
import {ElNotification} from "element-plus";
import {computed, defineProps, ref} from "vue";
import {useTenantAuthStore} from "@/stores/userInfo/tenantAuth";

let props = defineProps(['tenantAuthDataForm']);

let tenantAuthDataForm = computed(() => {return props['tenantAuthDataForm']});

let deleteLoading = ref(false);

let tenantAuthDeleteDialogVisible = computed(() => {return useTenantAuthStore().tenantAuthDeleteDialog});
let tenantAuthSearchData = computed(() => {return useTenantAuthStore().tenantAuthSearchData});

function cancelDialog() {
    useTenantAuthStore().resetTenantAuthDeleteDialog(false);
}

function submitDialog() {
    deleteLoading.value = true
    tenantAuthInfoDelete(tenantAuthDataForm.value).then(res => {
        if (res["code"] === '200') {
            ElNotification({
                title: 'Success',
                message: res["message"],
                type: 'success'
            });
            tenantAuthInfoQuery(tenantAuthSearchData.value).then(res => {
                useTenantAuthStore().resetTenantAuthDataList(res.data);
            })
            useTenantAuthStore().resetTenantAuthDeleteDialog(false);
        }
        deleteLoading.value = false
    }).catch(res => {
        deleteLoading.value = false
    })
}
</script>

<style scoped lang="less">

</style>